import axios from 'axios';
import { message } from 'antd';

const request = axios.create({
  baseURL: 'http://121.4.61.167:3002',
  timeout: 10000,
});

request.interceptors.request.use(
  config => {
    if (config.params) config.params._t = Date.now();
    return config;
  },
  err => {
    return Promise.reject(err);
  },
);

request.interceptors.response.use(
  res => {
    return res.data.body;
  },
  err => {
    message.error('请求失败');
    return Promise.reject(err);
  },
);

export default request;
